package com.tour.controller;


import com.tour.config.ResponseWrapper;
import com.tour.entity.Comment;
import com.tour.service.CommentService;
import com.tour.service.impl.CommentServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lel
 * @since 2020-12-30
 */
@Api(tags = "游客评论景区")
@RestController
@RequestMapping("/app/comment")
public class CommentController {

    @Autowired
    CommentServiceImpl commentService;

    @ApiOperation("发布景区评论")
    @PostMapping("/addComment")
    public ResponseWrapper addComment(@RequestBody Comment comment){
        ResponseWrapper wrapper= commentService.addComment(comment);
        return wrapper;
    }

    @ApiOperation("删除评论")
    @ApiImplicitParam(name = "commentId",value = "评论id")
    @DeleteMapping("/delComment")
    public ResponseWrapper delComment(@RequestParam(name = "commentId")Integer commentId){
        ResponseWrapper wrapper = commentService.delComment(commentId);
        return wrapper;
    }

    @ApiOperation("查询某个景区的所有评论")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "scenicId",value = "景区的id"),
            @ApiImplicitParam(name = "pageSize",value = "每页展示的数据条数",defaultValue = "10"),
            @ApiImplicitParam(name = "pageNum",value = "页码数",defaultValue = "1")
    })
    @GetMapping("/findAllComment")
    public ResponseWrapper findAllComment(@RequestParam(name = "scenicId")Integer scenicId,
                                          @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize,
                                          @RequestParam(name = "pageNum",defaultValue = "1")Integer pageNum){
        ResponseWrapper wrapper = commentService.findAllComment(scenicId,pageSize,pageNum);
        return wrapper;
    }


}

